package com.ruoyi.message.structures.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.message.structures.domain.PaperStructures;
import com.ruoyi.message.structures.service.IPaperStructuresService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 结构步骤Controller
 * 
 * @author ruoyi
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/structures/structures")
public class PaperStructuresController extends BaseController
{
    @Autowired
    private IPaperStructuresService paperStructuresService;

    /**
     * 查询结构步骤列表
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaperStructures paperStructures)
    {
        startPage();
        List<PaperStructures> list = paperStructuresService.selectPaperStructuresList(paperStructures);
        return getDataTable(list);
    }

    /**
     * 导出结构步骤列表
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:export')")
    @Log(title = "结构步骤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperStructures paperStructures)
    {
        List<PaperStructures> list = paperStructuresService.selectPaperStructuresList(paperStructures);
        ExcelUtil<PaperStructures> util = new ExcelUtil<PaperStructures>(PaperStructures.class);
        util.exportExcel(response, list, "结构步骤数据");
    }

    /**
     * 获取结构步骤详细信息
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:query')")
    @GetMapping(value = "/{structureId}")
    public AjaxResult getInfo(@PathVariable("structureId") Long structureId)
    {
        return success(paperStructuresService.selectPaperStructuresByStructureId(structureId));
    }

    /**
     * 新增结构步骤
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:add')")
    @Log(title = "结构步骤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperStructures paperStructures)
    {
        return toAjax(paperStructuresService.insertPaperStructures(paperStructures));
    }

    /**
     * 修改结构步骤
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:edit')")
    @Log(title = "结构步骤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperStructures paperStructures)
    {
        return toAjax(paperStructuresService.updatePaperStructures(paperStructures));
    }

    /**
     * 删除结构步骤
     */
    @PreAuthorize("@ss.hasPermi('structures:structures:remove')")
    @Log(title = "结构步骤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{structureIds}")
    public AjaxResult remove(@PathVariable Long[] structureIds)
    {
        return toAjax(paperStructuresService.deletePaperStructuresByStructureIds(structureIds));
    }
}
